<?php
namespace Cyfy;

/**
 * Manages various language settings
 *
 * Stores basic information about language settings.
 *
 * @category cyfy
 * @author Dandelion <dandelion8888@gmail.com>
 * @version 0.1
 */
class Language
{   
    /**
     * Currently active language
     * @var string
     */
    static public $active = "en";
    
    /**
     * Multi-language web page
     * @var bool
     */
    static public $multilanguage = false;

    /**
     * Returns true if more languages are to be used.
     * @return bool
     */
    static public function isMulti()
    {
        return self :: $multilanguage;
    }
    
    /**
     * Returns active language
     * @return string Active language
     */
    static public function getActive()
    {
        return self :: $active;
    }
    
    /**
     * Sets active language
     * @param string Language code
     */
    static public function setActive($lang)
    {
        self :: $active = $lang;
    }

    /**
     * Returns all available languages.
     * @return array Languages in associative array code => name.
     */
    static public function getAll()
    {
        if(!\Cyfy\Modules :: isEnabled("Translations"))
        {
            return array(self :: $active => self :: $active);   
        }
        return \Cyfy\Modules\Translations\Module :: getAll();
    }    
     
    /**
     * Loads languages.
     * Called on start of Cyfy.
     */
    static public function load()
    {
        if(\Cyfy\Modules :: isEnabled("Translations"))
        {
            self :: $multilanguage = true;
            \Cyfy\Modules\Translations\Module :: loadLanguage();
        }
    }
}